<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>入库单列表</title>
<link href="<%=path%>/css/core.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/pagination.css" rel="stylesheet"
	type="text/css" />
<link href="<%=path%>/css/list.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/xToolbar.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/jquery-impromptu.css" rel="stylesheet"
	type="text/css" />
</head>
<body>
	<div id="toolbar"></div>
	<form id="listForm" action="<%=path%>/stock/inOrder/listPagination.t4m"
		method="post">
		<table id="titleTable" cellpadding="0" cellspacing="0">
			<tr>
				<td>&nbsp;</td>
				<td><input type="checkbox" id="allBox" /></td>
				<td>入库单编号</td>
				<td>入库类型</td>
				<td>入库时间</td>
				<td>到货(退货)单编号</td>
				<td>采购日期</td>
				<td>经办人</td>
				<td>审批状态</td>
				<td>操作</td>
			</tr>
		</table>
		<table id="dataTable" cellpadding="0" cellspacing="0">
			<s:iterator id="inOrder" value="page.list" status="i">
				<tr class="row"
					ondblclick="viewOrder('<s:property value="#inOrder.id"/>')">
					<td class="num"><s:property value="#i.index+1" /></td>
					<td class="box"><s:if test="#inOrder.auditState != 2">
							<input type="checkbox" name="idList"
								value="<s:property value="#inOrder.id"/>" />
						</s:if>
					</td>
					<td><span><s:property value="#inOrder.code" /> </span></td>
					<td><span><s:if test="#inOrder.isBack==1">
						退货入库
					</s:if>
							<s:else>
						采购入库
					</s:else> </span></td>
					</td>
					<td><span><s:date name="#inOrder.inStockDate"
								format="yyyy-MM-dd HH:mm" /> </span></td>
					<s:if test="#inOrder.isBack==1">
						<td><span><s:property
									value="#inOrder.salesBackOrder.code" /> </span>
						</td>
					</s:if>
					<s:else>
						<td><span><s:property
									value="#inOrder.arriveOrder.code" /> </span>
						</td>
					</s:else>
					<td><span><s:date
								name="#inOrder.arriveOrder.purchaseOrder.orderDate"
								format="yyyy-MM-dd" /> </span></td>
					<td align="center"><span><s:property
								value="#inOrder.creator.realName" /> </span></td>
					<td><s:property
							value="@org.jxc.vo.KeyValue@getHtml(@org.jxc.constants.JXCString@AUDIT_STATE, #inOrder.auditState)" />
					</td>
					<td align="center"><s:if test="#inOrder.auditState == 0 || #inOrder.auditState == 3">
							<a
								href="javascript:applyBill('<s:property value="#inOrder.id"/>')">提交申请</a>
						</s:if> <s:elseif
							test="#inOrder.auditor.id == #session['LoginBean'].user.id && #inOrder.auditState == 1">
							<a
								href="javascript:auditBill('<s:property value="#inOrder.id"/>',2)">同意</a>
							<a
								href="javascript:auditBill('<s:property value="#inOrder.id"/>',3)">驳回</a>
						</s:elseif> <s:elseif
							test="#inOrder.auditState == 2 && #inOrder.storeState == 0">
							<a
								href="javascript:purchaseIn('<s:property value="#inOrder.id"/>')">生成入库单</a>
						</s:elseif> &nbsp;</td>
				</tr>
			</s:iterator>
		</table>
		<s:include value="/share/pagebar.jsp" />
	</form>

	<script src="<%=path%>/js/core.js" type="text/javascript"></script>
	<script src="<%=path%>/js/share.js" type="text/javascript"></script>
	<script src="<%=path%>/js/jquery.js" type="text/javascript"></script>
	<script src="<%=path%>/js/Grid.js" type="text/javascript"></script>
	<script src="<%=path%>/js/BoxSelect.js" type="text/javascript"></script>
	<script src="<%=path%>/js/xToolbar.js" type="text/javascript"></script>
	<script src="<%=path%>/js/xToolbar.items.js" type="text/javascript"></script>
	<script src="<%=path%>/js/jquery-impromptu.js" type="text/javascript"></script>
	<script type="text/javascript">
    function viewOrder(id) {
    	  top.inOrder.view(id);
      }
    function applyBill(inOrderId) {
    	document.getElementById("listForm").action = "<%=path%>/stock/inOrder/apply.t4m?inOrderId=" + inOrderId;
    	document.getElementById("listForm").submit();
    }
    function auditBill(inOrderId,result) {
    	document.getElementById("listForm").action = "<%=path%>/stock/inOrder/audit.t4m?inOrderId="
			+ inOrderId + "&auditState=" + result;
		document.getElementById("listForm").submit();
	}
    $(document).ready(function(){
      new Toolbar({
        id: '1',
        renderTo : 'toolbar',
        icon: '../../image/op.gif',
        items : [{
          type : 'button',
          text : '修改',
          useable : '<s:property value="@org.team4.util.Meta@getOperate(\"inOrder_edit\")"/>',
          position: {
            a: '-20px 0px',
            b: '-20px -120px'
          },
          handler : function(){
            if(getFirstID()) {
              top.inOrder.edit(getFirstID());
            }
          }
        },'-',{
	          type : 'button',
	          text : '删除',
	          position: {
	            a: '-40px 0px',
	            b: '-40px -120px'
	          },
	          useable : '<s:property value="@org.team4.util.Meta@getOperate(\"inOrder_delete\")"/>',
	          handler : function(){
					if(getFirstID())
					{
						var txt = '是否删除该信息？';
						$.prompt(txt,{
							buttons:{删除:true,取消:false},
							callback: function(v,m) {
								if(v) {
									document.getElementById('listForm').action = '<%=path%>/stock/inOrder/delete.t4m';
									document.getElementById('listForm').submit();
								}
							}
						});
					}
				}
			} ]
});

							new Grid({
								titleTable : 'titleTable',
								dataTable : 'dataTable',
								widths : [ 30, 24, 100, 150, 150, 100,100,
										100,100,100 ],
								height : function() {
									return getGridHeight({
										toolbarId : 'toolbar',
										hasPage : true
									});
								}
							});

							new BoxSelect({
								allId : 'allBox',
								boxName : 'idList'
							});

							loadReady();
						});
	</script>
</body>
</html>